package lab02.test30;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Average {
    static double average;
    public static void main(String[] args) {
        double numbers;
        Scanner student=new Scanner(System.in);
        List<Double> marks=new ArrayList<Double>();
        do{
            System.out.print("请输入学生成绩： ");
            numbers=student.nextDouble();
            marks.add(numbers);
        }
        while (numbers>=0);
        //当输入成绩为负数时，停止；
        int length=marks.size()-1;
        marks.remove(length);
        for(int i=0;i<length;i++){
            average+=marks.get(i)/length;
        }
        System.out.println(length+"名学生成绩的平均分： "+average);
    }
}
